package com.school;

import java.util.StringJoiner;

public class StringJoinerdemo1 {
    public static void main(String[] args) {
        //创建对象，并指定中间的间隔符号
        StringJoiner sj=new StringJoiner("----");//StringJoiner没有空参构造
        //添加元素
        sj.add("hello").add("world").add("java");

        StringJoiner sjj=new StringJoiner(",","[","]");
        sjj.add("1").add("2").add("3");
        int len=sjj.length();

        System.out.println(len);
        System.out.println(sjj);
        System.out.println(sj);

       String str1= sj.toString();
        String str2=sjj.toString();

        System.out.println(str1);
        System.out.println(str2);



    }
}
